function clearInitial(thisField, defaulttext) 
{
	if (thisField.value == defaulttext) 
        {
            thisField.value = "";
            thisField.style.color = "#000000";
        }
}

function clearReAuthPassword(thisField, defaulttext) 
{
	if (thisField.value == defaulttext) 
        {
            thisField.value = "";
            thisField.style.color = "#000000";
            thisField.type='password'
            document.getElementById('submitReAuth').disabled = false;
        }
}

function showLogin()
    {
        
        if(document.getElementById('header_login').style.visibility == "hidden")
            document.getElementById('header_login').style.visibility = "visible";
        else
            document.getElementById('header_login').style.visibility = "hidden";
        
    }
    
function showReAuth()
    {
        
        if(document.getElementById('reAuthCustomer').style.visibility == "hidden")
            document.getElementById('reAuthCustomer').style.visibility = "visible";
        else
            document.getElementById('reAuthCustomer').style.visibility = "hidden";
        
    }
    
function checkHeaderLogin()
{
    document.getElementById('loginSubmitButton').disabled = false;
 }

function checkRegLogin()
{
   document.getElementById('regSubmitLoginButton').disabled = false;
}

function validateLogin()
{
}
  
function addToCartCheck(formPath)
{   
    var noError = 1;
    //alert(formPath.quantity.value);
    
    if(isNaN(formPath.quantity.value) == true)
       noError = 1;
    else
       noError = 0;
   
   
        if(noError == 0)
        {
            return askConfirmation();
        }
    else
        {
            //alert(noError);
            alert("Please check values.");
            return false;
        }
        
}

function validatePasswordReset()
{   
    var formReset = new Array(3);
    var noError = 3;
    var count = 3;
    
    for(count = 2; count >= 0; count--)
        {
            formReset[count] = 0;
        }
    
    if (document.user_passReset.username.value != "Username"
                && document.user_passReset.username.value.length >= 8)
            {
                formReset[0] = 1; 
                document.user_passReset.username.style.backgroundColor = "#ffffff";
            }
            else
                {
                    formReset[0] = 0; 
                    document.user_passReset.username.style.backgroundColor = "#fdff76";
                }
    
    if (document.user_passReset.oldPassword.value != "Old Password"
                && document.user_passReset.oldPassword.value.length >= 3)
            {
                formReset[1] = 1; 
                document.user_passReset.oldPassword.style.backgroundColor = "#ffffff";
            }
            else
                {
                    formReset[1] = 0; 
                    document.user_passReset.oldPassword.style.backgroundColor = "#fdff76";
                }
                
     if (document.user_passReset.newPassword.value != "New Password"
                && document.user_passReset.newPassword.value.length >= 8
                && document.user_passReset.newPassword.value != "Retype New Password"
                && document.user_passReset.newPassword.value.length >= 8)
            {
                formReset[2] = 1; 
                document.user_passReset.newPassword.style.backgroundColor = "#ffffff";
                document.user_passReset.newPassword2.style.backgroundColor = "#ffffff";
           
            }
            else
                {
                    formReset[2] = 0; 
                    document.user_passReset.newPassword.style.backgroundColor = "#fdff76";
                    document.user_passReset.newPassword2.style.backgroundColor = "#fdff76";
                }
                
     for(count = 2; count >= 0; count--)
        {
            noError = noError - formReset[count];
        }
    
    if(noError == 0)
        {
            return askConfirmation();
        }
    else
        {
            //alert(noError);
            alert("Please check values.");
            return false;
        }
    
}

function checkLastInput(fieldName)
{   
    
}

function validateRegistration()
{
    var formComplete = new Array(24);
    var noError = 23;
    var count = 23;
    
    //initialize formComplete array
    for(count = 22; count >= 0; count--)
        {
            formComplete[count] = 0;
        }
    
    //validation here
    
            if (document.user_register.newUserLastName.value != "Last Name"
                && document.user_register.newUserLastName.value.length >= 2)
            {
                formComplete[0] = 1; 
                document.user_register.newUserLastName.style.backgroundColor = "#ffffff";
            }
            else
                {
                    formComplete[0] = 0; 
                    document.user_register.newUserLastName.style.backgroundColor = "#fdff76";
                }

            if (document.user_register.newUserFirstName.value != "First Name"
                && document.user_register.newUserFirstName.value.length >= 2)
            {
                formComplete[1] = 1; 
                document.user_register.newUserFirstName.style.backgroundColor = "#ffffff";
            }
            else
                {
                    formComplete[1] = 0; 
                    document.user_register.newUserFirstName.style.backgroundColor = "#fdff76";
                }

            if (document.user_register.newUserMiddleName.value != "Middle Initial"
                && document.user_register.newUserMiddleName.value.length != 0)
            {
                formComplete[2] = 1; 
                document.user_register.newUserMiddleName.style.backgroundColor = "#ffffff";
            }
            else
                {
                    formComplete[2] = 0; 
                    document.user_register.newUserMiddleName.style.backgroundColor = "#fdff76";
                }

            if (document.user_register.newUsername.value != "Username"
                && document.user_register.newUsername.value.length >= 8)
            {
                formComplete[3] = 1; 
                document.user_register.newUsername.style.backgroundColor = "#ffffff";
            }
            else
                {
                    formComplete[3] = 0; 
                    document.user_register.newUsername.style.backgroundColor = "#fdff76";
                }

            if (document.user_register.newPassword.value != "Password"
                && document.user_register.newPassword.value.length >= 8 
                && document.user_register.newPassword2.value != "Password"
                && document.user_register.newPassword2.value.length >= 8
                && document.user_register.newPassword.value == document.user_register.newPassword2.value)
            {
                formComplete[4] = formComplete[5] = 1; 
                document.user_register.newPassword.style.backgroundColor = "#ffffff";
                document.user_register.newPassword2.style.backgroundColor = "#ffffff";
            }
            else
                {
                    formComplete[4] = formComplete[5] = 0; 
                    document.user_register.newPassword.style.backgroundColor = "#fdff76";
                    document.user_register.newPassword2.style.backgroundColor = "#fdff76";
                }

            if (document.user_register.newEmail.value != "E-mail Address"
                && document.user_register.newEmail.value.length >= 8)
            {
                formComplete[6] = 1; 
                document.user_register.newEmail.style.backgroundColor = "#ffffff";
            }
            else
                {
                    formComplete[6] = 0; 
                    document.user_register.newEmail.style.backgroundColor = "#fdff76";
                }

            if (document.user_register.billingHouseNumber.value != "House Number"
                && document.user_register.billingHouseNumber.value.length >= 1)
            {
                formComplete[7] = 1; 
                document.user_register.billingHouseNumber.style.backgroundColor = "#ffffff";
            }
            else
                {
                    formComplete[7] = 0; 
                    document.user_register.billingHouseNumber.style.backgroundColor = "#fdff76";
                }

            if (document.user_register.billingStreet.value != "Street"
                && document.user_register.billingStreet.value.length >= 1)
            {
                formComplete[19] = 1; 
                document.user_register.billingStreet.style.backgroundColor = "#ffffff";
            }
            else
                {
                    formComplete[19] = 0; 
                    document.user_register.billingStreet.style.backgroundColor = "#fdff76";
                }

            if (document.user_register.billingSubdivision.value != "Subdivision"
                && document.user_register.billingSubdivision.value.length >= 1)
            {
                formComplete[8] = 1; 
                document.user_register.billingSubdivision.style.backgroundColor = "#ffffff";
            }
            else
                {
                    formComplete[8] = 0; 
                    document.user_register.billingSubdivision.style.backgroundColor = "#fdff76";
                }

            if (document.user_register.billingCity.value != "City"
                && document.user_register.billingCity.value.length >= 1)
            {
                formComplete[9] = 1; 
                document.user_register.billingCity.style.backgroundColor = "#ffffff";
            }
            else
                {
                    formComplete[9] = 0; 
                    document.user_register.billingCity.style.backgroundColor = "#fdff76";
                }

            if (document.user_register.billingPostalCode.value != "Postal Code"
                && document.user_register.billingPostalCode.value.length >= 1)
            {
                formComplete[10] = 1; 
                document.user_register.billingPostalCode.style.backgroundColor = "#ffffff";
            }
            else
                {
                    formComplete[10] = 0; 
                    document.user_register.billingPostalCode.style.backgroundColor = "#fdff76";
                }

            if (document.user_register.billingCountry.value != "Country"
                && document.user_register.billingCountry.value.length >= 1)
            {
                formComplete[11] = 1; 
                document.user_register.billingCountry.style.backgroundColor = "#ffffff";
            }
            else
                {
                    formComplete[12] = 0; 
                    document.user_register.billingCountry.style.backgroundColor = "#fdff76";
                }
        
            if (document.user_register.deliveryHouseNumber.value != "House Number"
                && document.user_register.deliveryHouseNumber.value.length >= 1)
            {
                formComplete[13] = 1; 
                document.user_register.deliveryHouseNumber.style.backgroundColor = "#ffffff";
            }
            else
                {
                    formComplete[13] = 0; 
                    document.user_register.deliveryHouseNumber.style.backgroundColor = "#fdff76";
                }

            if (document.user_register.deliveryStreet.value != "Street"
                && document.user_register.deliveryStreet.value.length >= 1)
            {
                formComplete[14] = 1; 
                document.user_register.deliveryStreet.style.backgroundColor = "#ffffff";
            }
            else
                {
                    formComplete[14] = 0; 
                    document.user_register.deliveryStreet.style.backgroundColor = "#fdff76";
                }

            if (document.user_register.deliverySubdivision.value != "Subdivision"
                && document.user_register.deliverySubdivision.value.length >= 1)
            {
                formComplete[15] = 1; 
                document.user_register.deliverySubdivision.style.backgroundColor = "#ffffff";
            }
            else
                {
                    formComplete[15] = 0; 
                    document.user_register.deliverySubdivision.style.backgroundColor = "#fdff76";
                }

            if (document.user_register.deliveryCity.value != "City"
                && document.user_register.deliveryCity.value.length >= 1)
            {
                formComplete[16] = 1; 
                document.user_register.deliveryCity.style.backgroundColor = "#ffffff";
            }
            else
                {
                    formComplete[16] = 0; 
                    document.user_register.deliveryCity.style.backgroundColor = "#fdff76";
                }

            if (document.user_register.deliveryPostalCode.value != "Postal Code"
                && document.user_register.deliveryPostalCode.value.length >= 1)
            {
                formComplete[17] = 1; 
                document.user_register.deliveryPostalCode.style.backgroundColor = "#ffffff";
            }
            else
                {
                    formComplete[17] = 0; 
                    document.user_register.deliveryPostalCode.style.backgroundColor = "#fdff76";
                }

            if (document.user_register.deliveryCountry.value != "Country"
                && document.user_register.deliveryCountry.value.length >= 1)
            {
                formComplete[18] = 1; 
                document.user_register.deliveryCountry.style.backgroundColor = "#ffffff";
            }
            else
                {
                    formComplete[18] = 0; 
                    document.user_register.deliveryCountry.style.backgroundColor = "#fdff76";
                }
                
           if (document.user_register.creditName.value != "Name on Card"
                && document.user_register.creditName.value.length >= 3)
            {
                formComplete[20] = 1; 
                document.user_register.creditName.style.backgroundColor = "#ffffff";
            }
            else
                {
                    formComplete[20] = 0; 
                    document.user_register.creditName.style.backgroundColor = "#fdff76";
                }
           
           if (document.user_register.creditCardNo.value != "Credit Card No."
                && document.user_register.creditCardNo.value.length >= 3)
            {
                formComplete[21] = 1; 
                document.user_register.creditCardNo.style.backgroundColor = "#ffffff";
            }
            else
                {
                    formComplete[21] = 0; 
                    document.user_register.creditCardNo.style.backgroundColor = "#fdff76";
                }
           
           if (document.user_register.creditCardType.selectedIndex != "0")
            {
                formComplete[22] = 1; 
                document.user_register.creditCardType.style.backgroundColor = "#ffffff";
            }
            else
                {
                    formComplete[22] = 0; 
                    document.user_register.creditCardType.style.backgroundColor = "#fdff76";
                }
                
           if (document.user_register.creditExpiryDate.value != "YYYY-MM-DD"
                && document.user_register.creditExpiryDate.value.length == 10)
            {
                formComplete[23] = 1; 
                document.user_register.creditExpiryDate.style.backgroundColor = "#ffffff";
            }
            else
                {
                    formComplete[23] = 0; 
                    document.user_register.creditExpiryDate.style.backgroundColor = "#fdff76";
                }
        
    
    for(count = 23; count >= 0; count--)
        {
            noError = noError - formComplete[count];
        }
    
    if(noError == 0)
        {
            return askConfirmation();
        }
    else
        {
            //alert(noError);
            alert("Please check values.");
            return false;
        }
}

function askConfirmation()
{
    var r = confirm("Continue?");
    if (r == true)
    {
      return true;
    }
    else
      return false;
}

function duplicateFields()
{   
    user_register.deliveryHouseNumber.value = user_register.billingHouseNumber.value;
    user_register.deliveryStreet.value = user_register.billingStreet.value;
    user_register.deliverySubdivision.value = user_register.billingSubdivision.value;
    user_register.deliveryCity.value = user_register.billingCity.value;
    user_register.deliveryPostalCode.value = user_register.billingPostalCode.value;
    user_register.deliveryCountry.value = user_register.billingCountry.value;
}




